package com.youlu.campus.admin.data.controller;

import com.youlu.campus.admin.utils.AuthUtils;
import com.youlu.campus.entity.VO.req.FileExportTaskQueryVO;
import com.youlu.campus.service.file.FileExportTaskService;
import com.yuelin.infrastructure.quantum.common.QResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

/**
 * 文件下载任务
 */
@RestController
@RequestMapping("/data")
public class FileExportTaskController {
    @Autowired
    private FileExportTaskService fileExportTaskService;

    @PostMapping("/file/task/list")
    public QResult exportTaskList(@RequestBody @NotNull FileExportTaskQueryVO req) {
        String tenantId = AuthUtils.getComId();
        req.setUserId(AuthUtils.getUserId());
        return QResult.success(fileExportTaskService.list(req));
    }

    @PostMapping("/file/task/download")
    public QResult downLoadFile(@RequestParam("id") String id, @RequestParam("token") String token) {
        String tenantId = AuthUtils.getComId();

        return QResult.success(fileExportTaskService.downLoad(id, token));
    }
}
